namespace unvs.human
{
    using System;
    using System.Data.Entity;
    using System.ComponentModel.DataAnnotations.Schema;
    using System.Linq;

    public partial class db : DbContext
    {
        public db()
            : base("name=db")
        {
        }

        public virtual DbSet<hrm_Departments> hrm_Departments { get; set; }
        public virtual DbSet<hrm_Employees> hrm_Employees { get; set; }
        public virtual DbSet<human_Persons> human_Persons { get; set; }
        public virtual DbSet<hrm_view_Employees> hrm_view_Employees { get; set; }

        protected override void OnModelCreating(DbModelBuilder modelBuilder)
        {
            modelBuilder.Entity<hrm_Departments>()
                .Property(e => e.KeyCode)
                .IsUnicode(false);

            modelBuilder.Entity<hrm_Departments>()
                .HasMany(e => e.hrm_Departments1)
                .WithOptional(e => e.hrm_Departments2)
                .HasForeignKey(e => e.ParentID);

            modelBuilder.Entity<hrm_Departments>()
                .HasMany(e => e.hrm_Employees)
                .WithRequired(e => e.hrm_Departments)
                .WillCascadeOnDelete(false);

            modelBuilder.Entity<human_Persons>()
                .HasOptional(e => e.hrm_Employees)
                .WithRequired(e => e.human_Persons);
        }
    }
}
